/**
 *  *2010-3-27 下午04:52:54  add 
 */
package com.base.myproject.client.ui;

import java.util.ArrayList;
import java.util.List;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.Grid;
import com.google.gwt.user.client.ui.HTML;

/**
 * @author Administrator
 *2010-3-27
 * javazgw@gmail.com
 */
public class HoursTable extends Grid {
	List<HoursButton> l = new ArrayList<HoursButton>();
	public HoursTable()
	{
		super(4,16);
		for(int i=0;i<32;i++)
		{
			l.add(new HoursButton() );
		}
		int k=0;
		for (int row = 0; row < 4; row+=2) {
		      for (int col = 0; col < numColumns; col++) {
		        this.setWidget(row, col, l.get(k++));
		      }
		    }
		int i=0;
		for (int row = 1; row < 4; row+=2) {
		      for (int col = 0; col < numColumns; col++) {
		        this.setWidget(row, col, new HTML("&nbsp; "+((i+col+16)/2)+((i+col+16)%2==0?":00":":30")));
		      }
		      i+=16;
		    }
		
		this.setCellPadding(1);
		this.setCellSpacing(1);
//		this.getStyleElement().setAttribute("border-collapse", "collapse");
//		this.getStyleElement().setAttribute("border-spacing", "0");
//		this.getStyleElement().setAttribute("style","border-right:#000 1px solid dotted;border-top:#000 1px solid dotted;border-left:#000 1px solid dotted;border-collapse:collapse;border-spacing:0;");
//		this.getStyleElement().setAttribute("border-right","#000 1px solid dotted");
//		this.getStyleElement().setAttribute("border-left","#000 1px solid dotted");
//		this.getStyleElement().setAttribute("border-top","#000 1px solid dotted");
//		this.getStyleElement().setAttribute("border-bottom","#000 1px solid dotted");
		this.setStyleName("Hourst");
//		this.getElement().getElementsByTagName("td").getItem(1).setAttribute("style", "padding:0");
//		this.getElement().getElementsByTagName("td").getItem(2).setAttribute("style", "padding:0");
		
	}
	public void setValue(int row,String key,String value)
	{
		l.get(row).add(key, value);
	}
	public void remove(int row,String key)
	{
		l.get(row).remove(key);
	}
	
	public void clear()
	{
		for(HoursButton hb:l)
		{
			hb.hm.clear();
			hb.paid();
		}
	}
	
	public void remove(String key)
	{
		for(HoursButton hb:l)
		{
			hb.hm.remove(key);
			hb.paid();
		}
	}

	public void removeexcept(String key)
	{
		for(HoursButton hb:l)
		{
			for(String keys :hb.hm.keySet())
			{
				GWT.log("keys="+keys+" key="+key, null);
				if(!(keys.equals(key)))
					hb.hm.remove(key);
			}
			//hb.hm.remove(key);
			hb.paid();
		}
		
	}
}
